<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>P-code machine</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/P-code_machine"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-P-code_machine rootpage-P-code_machine skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">P-code machine</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p class="mw-empty-elt">
</p><p>In <a href="Computer_programming" title="Computer programming">computer programming</a>, a <b>P-code machine</b> (<b>portable code machine</b><sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>) is a <a href="Virtual_machine" title="Virtual machine">virtual machine</a> designed to execute <i>P-code,</i> the <a href="Assembly_language" title="Assembly language">assembly language</a> or <a href="Machine_code" title="Machine code">machine code</a> of a hypothetical <a href="Central_processing_unit" title="Central processing unit">central processing unit</a> (CPU). The term <i>P-code machine</i> is applied generically to all such machines (such as the <a href="Java_virtual_machine" title="Java virtual machine">Java virtual machine</a> (JVM) and <a href="MATLAB" title="MATLAB">MATLAB</a> <a href="Bytecode" title="Bytecode">pre-compiled code</a>), as well as specific implementations using those machines. One of the most notable uses of P-Code machines is the P-Machine of the <a href="Pascal-P" class="mw-redirect" title="Pascal-P">Pascal-P</a> system. The developers of the <a href="UCSD_Pascal" title="UCSD Pascal">UCSD Pascal</a> implementation within this system construed the <i>P</i> in <i>P-code</i> to mean <i>pseudo</i> more often than <i>portable;</i> they adopted a unique label for <i>pseudo-code</i> meaning instructions for a pseudo-machine.
</p><p>Although the concept was first implemented circa 1966 as <a href="BCPL#Design" title="BCPL">O-code</a> for the Basic Combined Programming Language (<a href="BCPL" title="BCPL">BCPL</a>) and P code for the language <a href="Euler_(programming_language)" title="Euler (programming language)">Euler</a>,<sup id="cite_ref-Wirth_1966_2-0" class="reference"><a href="#cite_note-Wirth_1966-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> the <i>term</i> P-code first appeared in the early 1970s. Two early <a href="Compiler" title="Compiler">compilers</a> generating P-code were the Pascal-P compiler in 1973, by Kesav V. Nori, Urs Ammann, Kathleen Jensen, Hans-Heinrich Nägeli, and Christian Jacobi,<sup id="cite_ref-Nori_1975_3-0" class="reference"><a href="#cite_note-Nori_1975-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> and the <a href="Pascal-S" class="mw-redirect" title="Pascal-S">Pascal-S</a> compiler in 1975, by <a href="Niklaus_Wirth" title="Niklaus Wirth">Niklaus Wirth</a>.
</p><p>Programs that have been translated to P-code can either be <a href="Interpreter_(computing)" title="Interpreter (computing)">interpreted</a> by a software program that emulates the behaviour of the hypothetical CPU, or <a href="Binary_translation" title="Binary translation">translated</a> into the machine code of the CPU on which the program is to run and then executed. If there is sufficient commercial interest, a hardware implementation of the CPU specification may be built (e.g., the <a href="Pascal_MicroEngine" title="Pascal MicroEngine">Pascal MicroEngine</a> or a version of a <a href="Java_processor" title="Java processor">Java processor</a>).
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="P-code_versus_machine_code">P-code versus machine code</h2></div>
<p>While a typical <a href="Compiler" title="Compiler">compiler</a> model is aimed at translating a program code into <a href="Machine_code" title="Machine code">machine code</a>, the idea of a P-code machine follows a two-stage approach involving translation into P-code and execution by <a href="Interpreter_(computing)" title="Interpreter (computing)">interpreting</a> or <a href="Just-in-time_compilation" title="Just-in-time compilation">just-in-time compilation</a> (JIT) through the P-code machine.
</p><p>This separation makes it possible to detach the development of a P-code <a href="Interpreter_(computing)" title="Interpreter (computing)">interpreter</a> from the underlying machine code compiler, which has to consider machine-dependent behaviour in generating its <a href="Bytecode" title="Bytecode">bytecode</a>. This way a P-code interpreter can also be implemented quicker, and the ability to interpret the code at runtime allows for additional <a href="Run-time_checking" class="mw-redirect" title="Run-time checking">run-time checks</a> which might not be similarly available in native code. Further, as P-code is based on an ideal virtual machine, a P-code program can often be smaller than the same program translated to machine code. Conversely, the two-step interpretation of a P-code-based program leads to a slower execution speed, though this can sometimes be addressed with <a href="Just-in-time_compilation" title="Just-in-time compilation">just-in-time compilation</a>, and its simpler structure is easier to <a href="Reverse_engineering" title="Reverse engineering">reverse-engineer</a> than native code.
</p>
<div class="mw-heading mw-heading2"><h2 id="Implementations_of_P-code">Implementations of P-code</h2></div>
<p>In the early 1980s, at least two <a href="Operating_system" title="Operating system">operating systems</a> achieved <a href="Machine_independence" class="mw-redirect" title="Machine independence">machine independence</a> through extensive use of P-code . The <a href="Business_Operating_System_(software)" title="Business Operating System (software)">Business Operating System</a> (BOS) was a cross-platform <a href="Operating_system" title="Operating system">operating system</a> designed to run P-code programs exclusively. The <a href="UCSD_p-System" class="mw-redirect" title="UCSD p-System">UCSD p-System</a>, developed at The University of California, San Diego, was a self-compiling and <a href="Self-hosting_(compilers)" title="Self-hosting (compilers)">self-hosting</a> operating system based on P-code optimized for generation by the <a href="Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a> language.
</p><p>In the 1990s, translation into p-code became a popular strategy for implementations of languages such as <a href="Python_(programming_language)" title="Python (programming language)">Python</a>, <a href="Microsoft_P-Code" class="mw-redirect" title="Microsoft P-Code">Microsoft P-Code</a> in <a href="Visual_Basic" title="Visual Basic">Visual Basic</a> and <a href="Java_bytecode" title="Java bytecode">Java bytecode</a> in <a href="Java_(programming_language)" title="Java (programming language)">Java</a>.
</p><p>The language <a href="Go_(programming_language)" title="Go (programming language)">Go</a> uses a generic, portable assembly as a form of p-code, implemented by <a href="Ken_Thompson" title="Ken Thompson">Ken Thompson</a> as an extension of the work on <a href="Plan_9_from_Bell_Labs" title="Plan 9 from Bell Labs">Plan 9 from Bell Labs</a>. Unlike <a href="Common_Language_Runtime" title="Common Language Runtime">Common Language Runtime</a> (CLR) bytecode or JVM bytecode, there is no stable specification and the Go build tools do not emit a bytecode format to be used at a later time. The Go assembler uses the generic assembly language as an <a href="Intermediate_representation" title="Intermediate representation">intermediate representation</a> and the Go executables are machine-specific <a href="Statically_linked" class="mw-redirect" title="Statically linked">statically linked</a> binaries.<sup id="cite_ref-Pike_2016_4-0" class="reference"><a href="#cite_note-Pike_2016-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="UCSD_P-Machine">UCSD P-Machine</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Architecture">Architecture</h3></div>
<p>Like many other P-code machines, the UCSD P-Machine is a <a href="Stack_machine" title="Stack machine">stack machine</a>, which means that most instructions take their operands from a <a href="Stack_(abstract_data_type)" title="Stack (abstract data type)">stack</a>, and place results back on the stack. Thus, the <code>add</code> instruction replaces the two topmost elements of the stack with their sum. A few instructions take an immediate argument. Like Pascal, the P-code is <a href="Strong_and_weak_typing" title="Strong and weak typing">strongly typed</a>, supporting Boolean (b), character (c), integer (i), real (r), set (s), and pointer (a) <a href="Data_type" title="Data type">data types</a> natively.
</p><p>Some simple instructions:
</p>
<pre>Insn. Stack Stack Description
before after
adi i1 i2 i1+i2 add two integers
adr r1 r2 r1+r2 add two reals
inn i1 s1 b1 set membership; b1 = whether i1 is a member of s1
ldi i1 i1 i1 load integer constant
mov a1 a2 a2 move
not b1 b1 -b1 Boolean negation
</pre>
<div class="mw-heading mw-heading3"><h3 id="Environment">Environment</h3></div>
<p>Similar to a real target CPU, the P-System has only one stack shared by procedure stack frames (providing <a href="Return_statement" title="Return statement">return address</a>, etc.) and the arguments to local instructions. Three of the machine's <a href="Processor_register" title="Processor register">registers</a> point into the stack (which grows upwards):
</p>
<ul><li>SP points to the top of the stack (the <a href="Stack_pointer" class="mw-redirect" title="Stack pointer">stack pointer</a>).</li>
<li>MP marks the beginning of the active stack frame (the <a href="Mark_pointer" class="mw-redirect" title="Mark pointer">mark pointer</a>).</li>
<li>EP points to the highest stack location used in the current procedure (the extreme pointer).</li></ul>
<p>Also present is a constant area, and, below that, the <a href="Dynamic_memory_allocation" class="mw-redirect" title="Dynamic memory allocation">heap</a> growing down towards the stack. The NP (the new pointer) register points to the top (lowest used address) of the heap. When EP gets greater than NP, the machine's memory is exhausted.
</p><p>The fifth register, PC, points at the current instruction in the code area.
</p>
<div class="mw-heading mw-heading3"><h3 id="Calling_conventions">Calling conventions</h3></div>
<style data-mw-deduplicate="TemplateStyles:r1251242444">
/* start https://en.wikipedia.org/ */
.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style>
<p>Stack frames look like this:
</p>
<pre>EP ->
local stack
SP -> ...
locals
...
parameters
...
return address (previous PC)
previous EP
dynamic link (previous MP)
static link (MP of surrounding procedure)
MP -> function return value
</pre>
<p>The procedure calling sequence works as follows: The call is introduced with
</p>
<pre> mst n
</pre>
<p>where <code>n</code> specifies the difference in nesting levels (remember that Pascal supports nested procedures). This instruction will <i>mark</i> the stack, i.e. reserve the first five cells of the above stack frame, and initialize previous EP, dynamic, and static link. The caller then computes and pushes any parameters for the procedure, and then issues
</p>
<pre> cup n, p
</pre>
<p>to call a user procedure (<code>n</code> being the number of parameters, <code>p</code> the procedure's address). This will save the PC in the return address cell, and set the procedure's address as the new PC.
</p><p>User procedures begin with the two instructions
</p>
<pre> ent 1, i
ent 2, j
</pre>
<p>The first sets SP to MP + <code>i</code>, the second sets EP to SP + <code>j</code>. So <code>i</code> essentially specifies the space reserved for locals (plus the number of parameters plus 5), and <code>j</code> gives the number of entries needed locally for the stack. Memory exhaustion is checked at this point.
</p><p>Returning to the caller is accomplished via
</p>
<pre> retC
</pre>
<p>with <code>C</code> giving the return type (i, r, c, b, a as above, and p for no return value). The return value has to be stored in the appropriate cell previously. On all types except p, returning will leave this value on the stack.
</p><p>Instead of calling a user procedure (cup), standard procedure <code>q</code> can be called with
</p>
<pre> csp q
</pre>
<p>These standard procedures are Pascal procedures like <code>readln()</code> (<code>csp rln</code>), <code>sin()</code> (<code>csp sin</code>), etc. Peculiarly <code>eof()</code> is a p-Code instruction instead.
</p>
<div class="mw-heading mw-heading2"><h2 id="Example_machine">Example machine</h2></div>
<p><a href="Niklaus_Wirth" title="Niklaus Wirth">Niklaus Wirth</a> specified a simple p-code machine in the 1976 book <i><a href="Algorithms_%2B_Data_Structures_%3D_Programs" title="Algorithms + Data Structures = Programs">Algorithms + Data Structures = Programs</a></i>. The machine had 3 registers - a <a href="Program_counter" title="Program counter">program counter</a> <i>p</i>, a <a href="Stack_frame" class="mw-redirect" title="Stack frame">base register</a> <i>b</i> and a <a href="Stack_(data_structure)" class="mw-redirect" title="Stack (data structure)">top-of-stack register</a> <i>t</i>. There were 8 instructions:
</p>
<ol><li><code><b>lit</b> 0, <i>a</i></code> : load constant <style data-mw-deduplicate="TemplateStyles:r886049734">
/* start https://en.wikipedia.org/ */
.mw-parser-output .monospaced{font-family:monospace,monospace}
/* end https://en.wikipedia.org/ */
</style><span class="monospaced"><var style="padding-right: 1px;">a</var></span></li>
<li><code><b>opr</b> 0, <i>a</i></code> : execute operation <span class="monospaced"><var style="padding-right: 1px;">a</var></span> (13 operations: RETURN, 5 mathematical functions, and 7 comparison functions)</li>
<li><code><b>lod</b> <i>l</i>, <i>a</i></code> : load variable <span class="monospaced"><var style="padding-right: 1px;">l</var></span>, <span class="monospaced"><var style="padding-right: 1px;">a</var></span></li>
<li><code><b>sto</b> <i>l</i>, <i>a</i></code> : store variable <span class="monospaced"><var style="padding-right: 1px;">l</var></span>, <span class="monospaced"><var style="padding-right: 1px;">a</var></span></li>
<li><code><b>cal</b> <i>l</i>, <i>a</i></code> : call procedure <span class="monospaced"><var style="padding-right: 1px;">a</var></span> at level <span class="monospaced"><var style="padding-right: 1px;">l</var></span></li>
<li><code><b>int</b> 0, <i>a</i></code> : increment t-register by <span class="monospaced"><var style="padding-right: 1px;">a</var></span></li>
<li><code><b>jmp</b> 0, <i>a</i></code> : jump to <span class="monospaced"><var style="padding-right: 1px;">a</var></span></li>
<li><code><b>jpc</b> 0, <i>a</i></code> : jump conditional to <span class="monospaced"><var style="padding-right: 1px;">a</var></span><sup id="cite_ref-Hansotten_5-0" class="reference"><a href="#cite_note-Hansotten-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup></li></ol>
<p>This is the code for the machine, written in Pascal:
</p>
<div class="mw-highlight mw-highlight-lang-pascal mw-content-ltr" dir="ltr"><pre><span class="k">const</span>
<span class="w"> </span><span class="n">amax</span><span class="o">=</span><span class="mi">2047</span><span class="o">;</span><span class="w"> </span><span class="cm">{maximum address}</span>
<span class="w"> </span><span class="n">levmax</span><span class="o">=</span><span class="mi">3</span><span class="o">;</span><span class="w"> </span><span class="cm">{maximum depth of block nesting}</span>
<span class="w"> </span><span class="n">cxmax</span><span class="o">=</span><span class="mi">200</span><span class="o">;</span><span class="w"> </span><span class="cm">{size of code array}</span>
<span class="k">type</span>
<span class="w"> </span><span class="n">fct</span><span class="o">=</span><span class="p">(</span><span class="n">lit</span><span class="o">,</span><span class="n">opr</span><span class="o">,</span><span class="n">lod</span><span class="o">,</span><span class="n">sto</span><span class="o">,</span><span class="n">cal</span><span class="o">,</span><span class="nb">int</span><span class="o">,</span><span class="n">jmp</span><span class="o">,</span><span class="n">jpc</span><span class="p">)</span><span class="o">;</span>
<span class="w"> </span><span class="n">instruction</span><span class="o">=</span><span class="k">packed</span><span class="w"> </span><span class="k">record</span>
<span class="w"> </span><span class="n">f</span><span class="o">:</span><span class="n">fct</span><span class="o">;</span>
<span class="w"> </span><span class="n">l</span><span class="o">:</span><span class="mi">0</span><span class="o">..</span><span class="n">levmax</span><span class="o">;</span>
<span class="w"> </span><span class="n">a</span><span class="o">:</span><span class="mi">0</span><span class="o">..</span><span class="n">amax</span><span class="o">;</span>
<span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="k">var</span>
<span class="w"> </span><span class="n">code</span><span class="o">:</span><span class="w"> </span><span class="k">array</span><span class="w"> </span><span class="p">[</span><span class="mi">0</span><span class="o">..</span><span class="n">cxmax</span><span class="p">]</span><span class="w"> </span><span class="k">of</span><span class="w"> </span><span class="n">instruction</span><span class="o">;</span>
<span class="k">procedure</span><span class="w"> </span><span class="nf">interpret</span><span class="o">;</span>
<span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">stacksize</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">500</span><span class="o">;</span>
<span class="w"> </span><span class="k">var</span>
<span class="w"> </span><span class="n">p</span><span class="o">,</span><span class="w"> </span><span class="n">b</span><span class="o">,</span><span class="w"> </span><span class="n">t</span><span class="o">:</span><span class="w"> </span><span class="kt">integer</span><span class="o">;</span><span class="w"> </span><span class="cm">{program-, base-, topstack-registers}</span>
<span class="w"> </span><span class="n">i</span><span class="o">:</span><span class="w"> </span><span class="n">instruction</span><span class="o">;</span><span class="w"> </span><span class="cm">{instruction register}</span>
<span class="w"> </span><span class="n">s</span><span class="o">:</span><span class="w"> </span><span class="k">array</span><span class="w"> </span><span class="p">[</span><span class="mi">1</span><span class="o">..</span><span class="n">stacksize</span><span class="p">]</span><span class="w"> </span><span class="k">of</span><span class="w"> </span><span class="kt">integer</span><span class="o">;</span><span class="w"> </span><span class="cm">{datastore}</span>
<span class="w"> </span><span class="k">function</span><span class="w"> </span><span class="nf">base</span><span class="p">(</span><span class="n">l</span><span class="o">:</span><span class="w"> </span><span class="kt">integer</span><span class="p">)</span><span class="o">:</span><span class="w"> </span><span class="kt">integer</span><span class="o">;</span>
<span class="w"> </span><span class="k">var</span><span class="w"> </span><span class="n">b1</span><span class="o">:</span><span class="w"> </span><span class="kt">integer</span><span class="o">;</span>
<span class="w"> </span><span class="k">begin</span>
<span class="w"> </span><span class="n">b1</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">b</span><span class="o">;</span><span class="w"> </span><span class="cm">{find base l levels down}</span>
<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="n">l</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">do</span><span class="w"> </span><span class="k">begin</span>
<span class="w"> </span><span class="n">b1</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">b1</span><span class="p">]</span><span class="o">;</span>
<span class="w"> </span><span class="n">l</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">l</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span>
<span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="n">base</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">b1</span>
<span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="cm">{base}</span><span class="o">;</span>
<span class="k">begin</span>
<span class="w"> </span><span class="nb">writeln</span><span class="p">(</span><span class="s">' start pl/0'</span><span class="p">)</span><span class="o">;</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="mi">0</span><span class="o">;</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="mi">0</span><span class="o">;</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="mi">0</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="mi">0</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="mi">0</span><span class="o">;</span>
<span class="w"> </span><span class="k">repeat</span>
<span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">code</span><span class="p">[</span><span class="n">p</span><span class="p">]</span><span class="o">;</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span>
<span class="w"> </span><span class="k">with</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="k">do</span>
<span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="k">of</span>
<span class="w"> </span><span class="n">lit</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="n">opr</span><span class="o">:</span>
<span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="k">of</span><span class="w"> </span><span class="cm">{operator}</span>
<span class="w"> </span><span class="mi">0</span><span class="o">:</span>
<span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="cm">{return}</span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">3</span><span class="p">]</span><span class="o">;</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">2</span><span class="p">]</span><span class="o">;</span>
<span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">1</span><span class="o">:</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="o">-</span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="o">;</span>
<span class="w"> </span><span class="mi">2</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">3</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">4</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">5</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="k">div</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">6</span><span class="o">:</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nb">ord</span><span class="p">(</span><span class="nb">odd</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]))</span><span class="o">;</span>
<span class="w"> </span><span class="mi">8</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nb">ord</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">])</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">9</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nb">ord</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o"><></span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">])</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">10</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nb">ord</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">])</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">11</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nb">ord</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">])</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">12</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nb">ord</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">])</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="mi">13</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nb">ord</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o"><=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">])</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="n">lod</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">base</span><span class="p">(</span><span class="n">l</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">a</span><span class="p">]</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="n">sto</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">base</span><span class="p">(</span><span class="n">l</span><span class="p">)</span><span class="o">+</span><span class="n">a</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="o">;</span><span class="w"> </span><span class="nb">writeln</span><span class="p">(</span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">])</span><span class="o">;</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="n">cal</span><span class="o">:</span>
<span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="cm">{generate new block mark}</span>
<span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">base</span><span class="p">(</span><span class="n">l</span><span class="p">)</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">2</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">b</span><span class="o">;</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">3</span><span class="p">]</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">p</span><span class="o">;</span>
<span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="o">;</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">a</span>
<span class="w"> </span><span class="k">end</span><span class="o">;</span>
<span class="w"> </span><span class="nb">int</span><span class="o">:</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">a</span><span class="o">;</span>
<span class="w"> </span><span class="n">jmp</span><span class="o">:</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">a</span><span class="o">;</span>
<span class="w"> </span><span class="n">jpc</span><span class="o">:</span><span class="w"> </span><span class="k">begin</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">then</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">a</span><span class="o">;</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="k">end</span>
<span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="cm">{with, case}</span>
<span class="w"> </span><span class="k">until</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="o">;</span>
<span class="w"> </span><span class="nb">writeln</span><span class="p">(</span><span class="s">' end pl/0'</span><span class="p">)</span><span class="o">;</span>
<span class="k">end</span><span class="w"> </span><span class="cm">{interpret}</span><span class="o">;</span>
</pre></div>
<p>This machine was used to run Wirth's <a href="PL/0" title="PL/0">PL/0</a>, a Pascal subset compiler used to teach compiler development.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Microsoft_P-code">Microsoft P-code</h2></div>
<p>As the goal of the company was to release software for all the major platforms and architectures that existed then. Between 1980 and 1982, Microsoft developed an early C compiler that produced P-Code (the C language itself was not standardized and wouldn't be until later in the 80s). The P-Code allowed software to run on most platforms with minimal code change. UCSD Pascal was using a similar approach. This C to P-Code was a success but was very slow. In 1983, Microsoft released the Microsoft C Compiler, MSC, based on a license of the Lattice C compiler for versions 1.0 and 2.0; then, from version 3.0 onward, the MSC was a complete rewrite by Microsoft.<sup id="cite_ref-MS_C_3.0_7-0" class="reference"><a href="#cite_note-MS_C_3.0-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup>
</p><p><b>P-code</b> is a name later used by some of <a href="Microsoft" title="Microsoft">Microsoft</a>'s <a href="Intermediate_language" class="mw-redirect" title="Intermediate language">intermediate languages.</a> They provided an alternate binary format to machine code. At various times, Microsoft has said P-code is an abbreviation for either <i>packed code</i><sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> or <i>pseudo code</i>.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</p><p>Some Microsoft P-code flavor, quite different from the one used by the C compiler, was widely used with <a href="Visual_Basic_(classic)" title="Visual Basic (classic)">Visual Basic</a> which had a runtime that included a VM or could be directly compiled to native code. Like other P-code implementations, Microsoft P-code enabled a more compact <a href="Executable" title="Executable">executable</a> at the expense of slower execution.
</p>
<div class="mw-heading mw-heading2"><h2 id="Other_implementations">Other implementations</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">For example implementations, see <a href="Bytecode#Examples" title="Bytecode">Bytecode § Examples</a>.</div>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1266661725">
/* start https://en.wikipedia.org/ */
.mw-parser-output .portalbox{padding:0;margin:0.5em 0;display:table;box-sizing:border-box;max-width:175px;list-style:none}.mw-parser-output .portalborder{border:1px solid var(--border-color-base,#a2a9b1);padding:0.1em;background:var(--background-color-neutral-subtle,#f8f9fa)}.mw-parser-output .portalbox-entry{display:table-row;font-size:85%;line-height:110%;height:1.9em;font-style:italic;font-weight:bold}.mw-parser-output .portalbox-image{display:table-cell;padding:0.2em;vertical-align:middle;text-align:center}.mw-parser-output .portalbox-link{display:table-cell;padding:0.2em 0.2em 0.2em 0.3em;vertical-align:middle}@media(min-width:720px){.mw-parser-output .portalleft{margin:0.5em 1em 0.5em 0}.mw-parser-output .portalright{clear:right;float:right;margin:0.5em 0 0.5em 1em}}
/* end https://en.wikipedia.org/ */
</style>
<ul><li><a href="Bytecode" title="Bytecode">Bytecode</a></li>
<li><a href="Intermediate_representation" title="Intermediate representation">Intermediate representation</a></li>
<li><a href="Joel_McCormack" title="Joel McCormack">Joel McCormack</a>, designer of the NCR Corporation version of the p-code machine</li>
<li><a href="Runtime_system" title="Runtime system">Runtime system</a></li>
<li><a href="Token_threading" class="mw-redirect" title="Token threading">Token threading</a></li>
<li><a href="City_%26_Guilds_Mnemonic_Code" title="City & Guilds Mnemonic Code">City & Guilds Mnemonic Code</a></li>
<li>Platform-independent model</li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFUptonDuntemannRobertsMamtora2016" class="citation book cs1">Upton, Eben; Duntemann, Jeffrey; Roberts, Ralph; Mamtora, Tim; Everard, Ben (2016-09-13). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=mU5ICgAAQBAJ&q=In+computer+programming%2C+a+p-code+machine%2C+or+portable+code+machine&pg=PA187"><i>Learning Computer Architecture with Raspberry Pi</i></a>. John Wiley & Sons. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-1-119-18393-8</bdi>.</cite></span>
</li>
<li id="cite_note-Wirth_1966-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-Wirth_1966_2-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFWirthWeber1966" class="citation journal cs1"><a href="Niklaus_Wirth" title="Niklaus Wirth">Wirth, Niklaus</a>; Weber, Helmut (1966). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F365170.365202">"EULER: a generalization of ALGOL, and its formal definition: Part II"</a>. <i><a href="Communications_of_the_ACM" title="Communications of the ACM">Communications of the ACM</a></i>. <b>9</b> (2). New York, USA: <a href="Association_for_Computing_Machinery" title="Association for Computing Machinery">Association for Computing Machinery</a> (ACM): <span class="nowrap">89–</span>99. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F365170.365202">10.1145/365170.365202</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:12124100">12124100</a>.</cite></span>
</li>
<li id="cite_note-Nori_1975-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-Nori_1975_3-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFNoriAmmannJensenNägeli1975" class="citation book cs1">Nori, Kesav V.; Ammann, Urs; Jensen, Kathleen; Nägeli, Hans-Heinrich; Jacobi, Christian (1975). <i>The Pascal P Compiler Implementation Notes</i>. Zürich, Switzerland: <a href="Eidgen%C3%B6ssische_Technische_Hochschule" class="mw-redirect" title="Eidgenössische Technische Hochschule">Eidgenössische Technische Hochschule</a> (ETH).</cite></span>
</li>
<li id="cite_note-Pike_2016-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-Pike_2016_4-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFPike2016" class="citation web cs1"><a href="Robert_C._Pike" class="mw-redirect" title="Robert C. Pike">Pike, Robert C.</a> (2016). <a rel="nofollow" class="external text" href="https://www.youtube.com/watch?v=KINIAgRpkDA">"The Design of the Go Assembler"</a>. <i><a href="YouTube" title="YouTube">YouTube</a></i> (Conference talk). <a rel="nofollow" class="external text" href="https://ghostarchive.org/varchive/youtube/20211211/KINIAgRpkDA">Archived</a> from the original on 2021-12-11<span class="reference-accessdate">. Retrieved <span class="nowrap">2017-08-25</span></span>.</cite></span>
</li>
<li id="cite_note-Hansotten-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-Hansotten_5-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://pascal.hansotten.com/category/wirth/">"Category Archives: Wirth - Euler - Designed by Niklaus Wirth and Helmut Weber"</a>. <i>Pascal for small machines - Wirth languages, Pascal, UCSD, Turbo, Delphi, Freepascal, Oberon</i>. 2018-08-02.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite id="CITEREFAlpert1979" class="citation report cs1">Alpert, Donald (September 1979). <a rel="nofollow" class="external text" href="http://www.bitsavers.org/pdf/stanford/sel_techReports/TN164_A_Pascal_P-Code_Interpreter_for_the_Stanford_Emmy_Sep79.pdf">A Pascal P-Code Interpreter for the Stanford Emmy</a> <span class="cs1-format">(PDF)</span> (Report). Computer Systems Laboratory, Departments of Eleotrioal Engineering and Computer Scienoes, Stanford University. Technioal Note No. 164.</cite></span>
</li>
<li id="cite_note-MS_C_3.0-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-MS_C_3.0_7-0">^</a></b></span> <span class="reference-text"><cite class="citation journal cs1"><a rel="nofollow" class="external text" href="https://books.google.com/books?id=XxS89r_AA_0C&pg=PA71">"Software"</a>. <i>Computerworld</i>. <b>19</b> (15). Framingham, MA: CW Communications: 71. 1985-04-15. <a href="ISSN_(identifier)" class="mw-redirect" title="ISSN (identifier)">ISSN</a> <a rel="nofollow" class="external text" href="https://search.worldcat.org/issn/0010-4841">0010-4841</a>. <q>Microsoft has announced an enhanced version of its Microsoft C Compiler for the IBM Personal Computer… A vendor spokesman said Version 3.0 is the first C compiler developed internally by Microsoft.</q></cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite id="CITEREFPadawer1992" class="citation web cs1">Padawer, Andy (April 1992). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20010222035711/http://msdn.microsoft.com/library/backgrnd/html/msdn_c7pcode2.htm">"Microsoft P-Code Technology"</a>. <i><a href="Microsoft_Developer_Network" title="Microsoft Developer Network">Microsoft Developer Network</a></i>. Archived from <a rel="nofollow" class="external text" href="http://msdn.microsoft.com/library/backgrnd/html/msdn_c7pcode2.htm">the original</a> on 2001-02-22.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20070227000246/http://msdn.microsoft.com/library/en-us/vbcon98/html/vbconcompilingyourprojecttonativecode.asp">"Compiling Your Project to Native Code"</a>. <i>Visual Studio 6.0 Documentation</i>. 2007. Archived from <a rel="nofollow" class="external text" href="http://msdn.microsoft.com/library/en-us/vbcon98/html/vbconcompilingyourprojecttonativecode.asp">the original</a> on 2007-02-27.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2></div>
<ul><li><cite id="CITEREFPembertonDaniels" class="citation book cs1"><a href="Steven_Pemberton" title="Steven Pemberton">Pemberton, Steven</a>; Daniels, Martin. <a rel="nofollow" class="external text" href="http://www.cwi.nl/~steven/pascal/book/"><i>Pascal Implementation: The P4 Compiler and Interpreter</i></a>. <a href="John_Wiley_(publisher)" class="mw-redirect" title="John Wiley (publisher)">John Wiley</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-13-653031-1</bdi>.</cite></li>
<li><cite id="CITEREFPemberton2011" class="citation web cs1"><a href="Steven_Pemberton" title="Steven Pemberton">Pemberton, Steven</a>, ed. (2011-04-13). <a rel="nofollow" class="external text" href="http://homepages.cwi.nl/~steven/pascal/">"Pascal Implementation: A Book and Sources"</a>.</cite> (NB. Has Pascal sources of the <a href="Pascal-P4" class="mw-redirect" title="Pascal-P4">P4</a> compiler and interpreter, usage instructions.)</li>
<li><cite id="CITEREFPemberton2011" class="citation web cs1"><a href="Steven_Pemberton" title="Steven Pemberton">Pemberton, Steven</a>, ed. (2011-04-13). <a rel="nofollow" class="external text" href="http://homepages.cwi.nl/~steven/pascal/pcom-code4.txt">"pcode of the Pascal Compiler as compiled by itself"</a>.</cite> (NB. Has the P-code of the <a href="Pascal-P4" class="mw-redirect" title="Pascal-P4">P4</a> compiler, generated by itself.)</li>
<li><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.threedee.com/jcm/psystem/">"The Jefferson Computer Museum's page on the UCSD p-System"</a>.</cite></li>
<li><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://ucsd-psystem-vm.sourceforge.net/">"Open Source implementation"</a>.</cite>, including packaging and pre-compiled binaries; a friendly fork of the <cite id="CITEREFKlebsch" class="citation web cs1">Klebsch. <a rel="nofollow" class="external text" href="http://www.klebsch.de">"Klebsch implementation"</a>.</cite></li>
<li><cite id="CITEREFTerry2005" class="citation book cs1">Terry, Pat (2005). <i>Compiling with C# and Java</i>. Pearson/Addison-Wesley. p. 624. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-321-26360-X</bdi>.</cite></li>
<li><cite id="CITEREFWirth1975" class="citation book cs1"><a href="Niklaus_Wirth" title="Niklaus Wirth">Wirth, Niklaus</a> (1975). <a href="Algorithms_%2B_Data_Structures_%3D_Programs" title="Algorithms + Data Structures = Programs"><i>Algorithms + Data Structures = Programs</i></a>. Prentice-Hall. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-13-022418-9</bdi>.</cite></li>
<li><cite id="CITEREFWirth1996" class="citation book cs1"><a href="Niklaus_Wirth" title="Niklaus Wirth">Wirth, Niklaus</a> (1996). <i>Compiler Construction</i>. Addison-Wesley. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-201-40353-6</bdi>.</cite></li>
<li><cite id="CITEREFLiffick1979" class="citation book cs1">Liffick, Blaise W., ed. (1979). <i>The Byte Book of Pascal</i>. BYTE Publications. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-07-037823-1</bdi>.</cite></li>
<li><cite id="CITEREFBarron1981" class="citation book cs1"><a href="David_William_Barron" class="mw-redirect" title="David William Barron">Barron, David William</a>, ed. (1981). <i>Pascal: The Language and its Implementation</i>. Wiley. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-471-27835-1</bdi>.</cite> (NB. Especially see the articles <i>Pascal-P Implementation Notes</i> and <i>Pascal-S: A Subset and its Implementation</i>.)</li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20151222171103/http://www.woodmann.com/crackz/Tutorials/Vbpcode.htm">VB P-code Information by Mr Silver</a> at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a> (archived December 22, 2015)</li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox authority-control" aria-label="Navbox405" style="padding:3px"><table class="nowraplinks hlist navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Authority control databases: National </th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"><ul><li><span class="uid"><a rel="nofollow" class="external text" href="https://id.loc.gov/authorities/n92062941">United States</a></span></li></ul></div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-16" href="https://en.wikipedia.org/wiki/?title=P-code_machine&oldid=1300819614">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>